// Promise-失败
<template>
  <div>
    <prism language="javascript">
      var promise = new Promise(function(resolve, reject) {
      // 异步处理代码处
      // resolve("yuan");
      reject("失败了:(");
      });

      //失败之后的处理
      promise.then(
      function(data) {
      console.log("data from promise: " + data);
      },
      function(error) {
      console.log("error from promise: " + error);
      }
    </prism>
    <v-btn
      round
      color="success"
      @click="run"
    >
      RUN
    </v-btn>
  </div>
</template>

<script>
import Prism from "vue-prism-component";
export default {
  components: {
    Prism
  },
  methods: {
    run() {
      var promise = new Promise(function(resolve, reject) {
        // 异步处理代码处
        // resolve("yuan");
        reject("失败了:(");
      });

      //失败之后的处理
      promise.then(
        function(data) {
          console.log("data from promise: " + data);
        },
        function(error) {
          console.log("error from promise: " + error);
        }
      );
    }
  }
};
</script>